package com.itheima.d7_thread_communication;

import static java.lang.Thread.sleep;

public class Dinn implements Runnable{
    @Override
    public void run() {
        while(true){
            synchronized (Desk.class){
                if(Desk.flag){
                    System.out.println("吃吃吃");
                    Desk.flag=false;
                }
                Desk.class.notify();
                try {
                    Desk.class.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                try {
                    sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }

    }
}
